perm filename VALIO.PAL[AL,HE]3 blob sn#526812 filedate 1980-07-29 generic text, type C, neo UTF8
COMMENT āŠ—   VALID 00003 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	DZ11 definitions & Initialization routine
C00004 00003	 Routine to send a message from AL to the PUMA.
C00008 ENDMK
CāŠ—;
;DZ11 definitions & Initialization routine

DZCSR  = 160000		;Control and Status register
DZLPR  = 160002		;Line Parameter register      (write only)
DZRBUF = 160002		;Receiver Buffer register     (read  only)
DZTCR  = 160004		;Transmitter Control register (byte)
DZTBUF = 160006		;Transmitter Buffer	      (byte, write only)

CODE

VALINI:	MOV  #12430,R0		;Line parameters: 300 baud, 8 char, no parity
	BIS  VALINE,R0		;Choose which line
	MOV  R0,DZLPR		;Tell DZ11 what parameters to use
	MOV  #1,R0
	ASH  VALINE,R0		;Set up transmit bit for line we're using
	MOVB R0,DZTCR		;Turn on transmit for line
	BIS  #40,DZCSR		;Turn on master scan enable
	CLRB VALOCK		;Reset lock flag
	RTS  PC			;Return to caller.

; Routine to send a message from AL to the PUMA.

; Parameters:  R1 - Points to an ASCIZ string which is to be sent to VAL.
;		    This string will have a CR appended to it when sent.
;	       R2 - If this is zero, the routine will return immediately,
;		    but if it is nonzero, it will wait for VAL to print a
;		    period (.) to signify that it has completed the
;		    instruction we sent it.
; R0 is clobbered

; Transmit the message to VAL

VALSND: TSTB VALOCK		;Is this routine locked?
	BEQ  1$			;If not, continue and send msg.
	ALERR VALMSG		;It was locked (already in use). Show error msg
	RTS  PC			;And return

1$:	INCB VALOCK		;Lock this routine
	MOV  R2,-(SP)		;Remember whether we're to wait or not

; Send the message over to VAL

2$:	MOVB (R1)+,R0		;Get next char to send
	BEQ  4$			;If end of msg, exit
	CMPB R0,#141		;Is char < "a"?
	BLT  3$			;If so, don't convert to upper case
	CMPB R0,#172		;Also if char is above "z"
	BGT  3$
	SUB  #40,R0		;Convert to upper case
3$:	JSR  PC,VALCHR		;Send the char, wait for the echo
	BR   2$			;Go send more
4$:	MOVB #15,R0		;End of msg.  Add a carriage return
	JSR  PC,VALCHR		;Send the CR

	TST  (SP)+		;Should we hang around or return?
	BEQ  10$		;If nonzero, wait for period

; Now wait for VAL to type a "." to let us know it's done.

5$:	MOV #10,R1
6$:	MOV DZRBUF,R0		;See if anything new for us from VAL
	BMI 7$			; Yes - skip ahead
	SLEEP #250.		; No - wait 1/4 sec, then check again
	SOB R1,6$
	MOVB #15,R0		;Every 2 seconds send a carriage return over
	JSR PC,VALCHR		;Send the CR
	BR 5$
7$:	CMPB R0,#56		;Is it a period?
	BNE 5$			; No, keep looking

10$:	DECB VALOCK		;unlock routine
	RTS  PC			;return to AL caller.

; Auxillary routine to send characters to VAL & wait for them to be echoed

VALCHR:	TST  DZCSR		;Can we send it yet?
	BPL  VALCHR		; No - wait til we can
	MOVB R0,DZTBUF		;Send the char over
1$:	MOV  DZRBUF,R2		;See if any chars to receive. Is this a new char?
	BPL  1$			;If not, keep looking
	CMPB R0,R2		;Is char echoed yet?
	BNE  1$			;If not, try again
	RTS  PC

; Data & Constants

DATA

VALINE:: .WORD 0		;Which DZ11 line we are using
VALOCK:: .BYTE 0		;To control entry to this routine (a lock)
VALMSG:: .ASCIZ /VAL ALREADY IN USE -- YOU LOSE/

.EVEN